<html>
<head>
<meta charset="utf-8"/>
<title>heishenhua</title>
</head>
<body onload="alert('页面加载完成！')">

<form action="payment.jsp" method="GET">
	<input type="text" name="book">
	<input type="submit" value="下单" />
</form>

<script>
	function myfunc(){
		alert('mmmm')
	}
	function compute_fact(){

        var xhr = new XMLHttpRequest();

        xhr.open("GET", "http://localhost:8080/myapp/factorial_service.jsp?number=5", true);
  

        xhr.onreadystatechange = function(){
                if (xhr.readyState === 4 && xhr.status === 200) {
                    
					var fact = xhr.responseText;
					input= document.getElementById("result");
					input.value = fact;
                }                
            }
		xhr.send();
		//http://localhost:8080/myapp/factorial_service.jsp,拿到结果
		



	}
</script>
<form action="factorial_sevice.jsp" method="GET">
	<input type="text" name="number">
	<input type="button" value="计算阶乘" onclick="compute_fact()"/>
</form>

<input type="text" value="xx" id = "result"/>
</body>
</html>